<!--
 * @Date: 2022-08-04 16:29:35
 * @LastEditors: StavinLi
 * @LastEditTime: 2022-09-21 14:14:32
 * @FilePath: /Workflow/src/components/drawer/copyerDrawer.vue
-->
<template>
    <el-drawer :append-to-body="true" title="抄送人设置" :visible.sync="showCopy" direction="rtl" class="set_copyer" size="550px" :before-close="saveCopyer">

      
      <div class="list">
        <el-button type="primary" size="small" @click="showDialog()">添加/修改抄送人</el-button>
        <div class="personnel_box">
          <el-tag
            style="margin:5px"
            v-for="tag in csrList"
            :key="tag.id" >
            {{tag.label}}
          </el-tag> 
        </div>
      </div>
      <div class="footer">
        <el-button type="primary" @click="saveCopyer">确 定</el-button>
        <el-button @click="closeDrawer">取 消</el-button>
      </div>
      <personnelDialog ref="personnel"  @selectList='selectListFun' :type="type" :transmitIdList="idList" ></personnelDialog> 
    </el-drawer>
</template>
<script>
import personnelDialog from '../dialog/personnelDialog.vue'
import { mapState, mapMutations } from 'vuex'
export default {
    components: {
        personnelDialog
    },
    props:['showCopy', 'nodeInfo'],
    data() {
        return {
            copyerConfig: {},
            ccSelfSelectFlag: [],
            copyerVisible: false,
            checkedList: [],
            csrList:[],
            type:2,
            idList:[]
        }
    },
    computed: {
        ...mapState(['copyerDrawer', 'copyerConfig1']),
    },
    watch: {
      showCopy(){
        if(this.nodeInfo.csr&&this.nodeInfo.csr.length>0){
          this.csrList = this.nodeInfo.csr
          this.idList = []
          this.csrList.map((item)=>{
            this.idList.push(item.id)
          })
          console.log(this.idList,'-----------触发监听---------------')
        }
        
      }
    },
    methods: {
        
        saveCopyer() {
          this.$parent.makeUserList = this.csrList
          this.closeDrawer();
        },
        closeDrawer() {
          this.$emit('hideCopy',false)
        },
        selectListFun(val){
          console.log(val,'----------传过来的值---------------')
          let ss = JSON.stringify(val)
          let aa = JSON.parse(ss)
          this.csrList = aa
          console.log(this.csrList,'------------改变后的值----------')
        },
        showDialog(){
          this.$refs.personnel.isPersonnel = true
        }
        
    }
}
</script>

<style lang="less" scoped>
  .list{
    padding: 20px;
    box-sizing: border-box;
  }
</style>